//
//  DFBaseTableViewController.swift
//  新浪微博
//
//  Created by dafei on 16/5/21.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class DFBaseTableViewController: UITableViewController,DFVistorLoginViewDelegate{

    //根据用户是否登录显示 登录页面还是访客视图页面
//      var userLogin = true
//    var userLogin = DFUserAccountViewModel.sharedAccountViewModel.loadUserAccount() != nil
      var userLogin = DFUserAccountViewModel.sharedAccountViewModel.userLogin
    //添加访客视图的属性
    lazy var visitorLoginView: DFVistorLoginView = DFVistorLoginView()
    
    //重写loadView
    override func loadView() {
        if userLogin {
            //显示tableVIew
            super.loadView()
        } else {
            //显示访客视图
            self.loadVisitorView()
        }
    }
    
    private func loadVisitorView() {
        //        let v = HMVisitorLoginView()
        view = visitorLoginView
        visitorLoginView.visitorDelegate = self
    }
    //MARK 实现协议
    func userWilllogin() {
        print("登录")
        
        let oauth = DFOAuthViewController()
//        let oauth = DFWelcomeViewController()

        let nav = UINavigationController(rootViewController: oauth)
        
        //modal 
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func userWillRegister() {
        print("注册")
    }
    
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source
//
//    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
//        // #warning Incomplete implementation, return the number of sections
//        return 1
//    }
//
//    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//        // #warning Incomplete implementation, return the number of rows
//        return 0
//    }

    /*
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)

        // Configure the cell...

        return cell
    }
    */

}
